<template>
	<view class="content">
		<view class="item">
			<view class="title">{{ obj.project_name }}</view>
			<view class="type">项目类型：{{ obj.cate_name }}</view>
			<view class="type">服务项目：{{ obj.cate_names }}</view>
			<view class="type">亩数：{{ obj.number }}亩</view>
			<view class="name">申请人信息</view>
			<view class="info">{{ obj.contactor }}：{{ obj.contactor_phone }}</view>
			<view class="info">{{ obj.address }}</view>
			<view class="time">申请时间：{{ obj.createtime_text }}</view>
			<view class="time" >服务人员:</view>
		</view>
		<view class="bot">
			<text>分配给：</text>
			<ms-dropdown-menu><ms-dropdown-item v-model="value1" :list="list"></ms-dropdown-item></ms-dropdown-menu>
		</view>
		<view class="footer" @tap="submit">分配</view>
		<!-- 分配成功弹窗 -->
		<u-popup @close="close" class="pop" v-model="pop_show" mode="center" width="581rpx" height="524rpx" :closeable="true">
			<image src="../../../static/item5.png" mode=""></image>
			<text>项目分配成功</text>
			<view class="btn" @tap="payEnd">完成</view>
		</u-popup>
	</view>
</template>

<script>
import msDropdownMenu from '@/components/ms-dropdown/dropdown-menu.vue';
import msDropdownItem from '@/components/ms-dropdown/dropdown-item.vue';
export default {
	components: {
		msDropdownMenu,
		msDropdownItem
	},
	data() {
		return {
			list: [],
			user_id: '',
			value1:0,
			pop_show: false, //
			obj: {},
			Tuser_id:''
			
		};
	},
	onLoad(options) {
		console.log(options)
		this.user_id = options.user_id;
		this.loadData();
		this.getList();
		console.log(this.user_id+"2222")
	},
	methods: {
		submit() {
			this.$http
				.post('/api/userinfo/fenpei', {
					order_id: this.obj.order_id,
					user_id: this.value1,
				})
				.then(res => {
					console.log(this.value1)
					this.pop_show = true;
				});
			   // console.log(this.list)
			// let token = uni.getStorageSync('token');
			// uni.request({
			// 	url: this.$baseUrl + '/api/userinfo/fenpei',
			// 	data: {
			// 		token,
			// 		order_id: this.obj.order_id,
			// 		user_id: this.list[1].value1
			// 	},
			// 	success: res => {
			// 		this.pop_show = true;
			// 	}
			// });
		},
		payEnd() {
			this.pop_show = false;
			uni.navigateTo({
				url: '/pages/componentB/nonghu/nonghu'
			})
			
		},
		//弹出层右上关闭按钮
		close() {
			// console.log('关闭了')
			this.pop_show = false;
			// uni.navigateBack({
			// 	delta:1
			// })
		},
		loadData(id) {
				console.log(this.user_id+"1111")
			this.$http
				.post('/api/order/detail', {
					id: this.user_id
				})
				.then(res => {
					this.obj = res.data.data;
					 console.log(res.data)
				});
		},
		//获取服务人员列表
		getList() {
			 console.log(this.user_id+"aaa")
			this.$http.post('/api/userinfo/townserveuser',{
				order_id: this.user_id,
				user_id:this.user_id}).then(res => {
				let test = Object.entries(res.data.data);
				// console.log(test);
				let arr = Object.entries(res.data.data);
				arr.forEach((item, index) => {
					this.list.push({
					    text: item[1].nickname,
						value: item[1].user_id,
					});
					
				});
				 // console.log(this.list)
				// this.list.forEach((item,index)=>{
				// 	this.index1.push({
				// 		user_id:item.value
				// 	});
				// 	console.log(this.index1)
				// })
				// var array=[]
				// array.push(this.list[index].value1)
				// console.log(this.array)
				
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.content {
	min-height: 100vh;
	background-color: #f8f8f8;
	padding: 30rpx;
	box-sizing: border-box;
}
.item {
	padding: 30rpx;
	box-sizing: border-box;
	width: 690rpx;
	background: rgba(255, 255, 255, 1);
	border-radius: 20px;
	margin-bottom: 30rpx;
	// height: 540rpx;
	.title {
		font-size: 17px;
		font-family: PingFang SC;
		font-weight: bold;
		color: rgba(51, 51, 51, 1);
	}
	.type {
		font-size: 15px;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
		margin-top: 29rpx;
	}
	.name {
		font-size: 17px;
		font-family: PingFang SC;
		font-weight: bold;
		color: rgba(51, 51, 51, 1);
		margin-top: 50rpx;
	}
	.info {
		font-size: 16px;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
		margin-top: 28rpx;
	}
	.time {
		font-size: 17px;
		font-family: PingFang SC;
		font-weight: bold;
		color: rgba(63, 195, 119, 1);
		margin-top: 43rpx;
	}
}
.bot {
	// width:690px;
	background: rgba(255, 255, 255, 1);
	border-radius: 20px;
	margin: 30rpx auto 0;
	padding: 20rpx 30rpx;
	box-sizing: border-box;
	display: flex;
	justify-content: space-between;
	align-items: center;
	text {
		font-size: 17px;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
	}
}
.footer {
	width: 535rpx;
	height: 88rpx;
	background: rgba(63, 195, 119, 1);
	border-radius: 10px;
	margin: 70rpx auto;
	line-height: 88rpx;
	text-align: center;
	font-size: 15px;
	font-family: PingFang SC;
	font-weight: bold;
	color: rgba(255, 255, 255, 1);
}
.pop {
	padding: 24rpx;
	box-sizing: border-box;
	border-radius: 10px;
	image {
		width: 93rpx;
		height: 104rpx;
		display: block;
		margin: 70rpx auto;
	}
	text {
		font-size: 18px;
		font-family: PingFang SC;
		font-weight: bold;
		color: rgba(51, 51, 51, 1);
		text-align: center;
		display: block;
	}
	.btn {
		width: 535rpx;
		height: 88rpx;
		background: rgba(63, 195, 119, 1);
		border-radius: 10px;
		margin: 68rpx auto 0;
		line-height: 88rpx;
		text-align: center;
		font-size: 15px;
		font-family: PingFang SC;
		font-weight: bold;
		color: rgba(255, 255, 255, 1);
	}
}
</style>
